import React from 'react';
import { connect } from 'dva';
import router from 'umi/router';

import { Table, Button } from 'antd';

import Link from 'umi/link'

const linePath = '/HR/HrContract';
const formPath = '/HR/HrContractForm';

@connect(({ hrContract }) => ({ hrContract }))
class List extends React.Component {
  state = {
  }

  treeview = [
      {
        title: '',
        dataIndex: '_',
        render: (_, { id }) => {
          return <Link to={`${linePath}?id=${id}`}>查看</Link>;
        },
      },
      { title: '名称', dataIndex: 'name', },
      { title: '员工', dataIndex: 'employee_id.name', },
      { title: '日期', dataIndex: 'date_start', },
  ]

  async componentDidMount() {
    const { dispatch } = this.props;
    await dispatch({
      type: 'hrContract/search',
      payload: {domain:[] },

    });

  }

  gotoForm() {
      router.push(formPath);
  }

  render() {
    const { hrContract: { recordsList } } = this.props;

    return (
      <div>
        <Button onClick={()=>this.gotoForm()}>新建</Button>
        <Table columns={this.treeview} dataSource={recordsList} rowKey="id" />

      </div>
    );
  }
}

export default List;





